<!-- SELECT2 EXAMPLE -->
<div class="box box-default">
	<div class="box-header with-border">
		<h3 class="box-title">添加图片</h3>
	</div>
	<!-- /.box-header -->
	<div class="box-body">
		<div class="row">
			<div class="col-md-11">
				<form class="form-horizontal" action="/manage/slide/save" method="post" name="myform" id="myform">
					
					<div class="form-group">
						<label class="col-md-2 non-rpad control-label" for="link">链接：</label>
						<div class="col-md-6 non-lrpad" style="line-height: 24px">
							<input type="text" name="link" id="link" class="form-control" value="<!--{$data['link']}-->" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 non-rpad control-label">轮播图：</label>
						<div class="col-xs-6 non-lrpad" style="line-height: 35px">
							<div class="col-xs-6">
								<button type="button" class="btn btn-success col-xs-10">+上传图片</button>
								<input type="file" name="upload" id="pic" class="col-xs-10 btn-translatefile" onchange="ajaxFileUpload('pic');"> 
								<input type="hidden" name="pic" id="field_pic" autocomplete="off" value="<!--{$data['pic']}-->"> 
								<img id="file_pic" src="<!--{$data['pic']}-->" class="uplaod">
							</div>
							<span class="col-xs-6">尺寸：1920*528</span>
						</div>
					</div>	
					<div class="form-group">
						<label class="col-xs-2 non-rpad control-label" for="sort">排序：</label>
						<div class="col-xs-6 non-lrpad" style="line-height: 24px">
							<input type="text" required name="sort" id="sort" class="form-control" value="<!--{$data['sort']}-->" />
						</div>
					</div>
					<div class="form-group">
						<!--{if($id)}-->
						<input type="hidden" name="id" value="<!--{$id}-->">
						<!--{/if}-->
						<input class="col-md-2 col-md-offset-5 btn btn-success" type="submit" value="提交" />
					</div>
				</form>
			</div>

		</div>
		<!-- /.row -->
	</div>
	<!-- /.box-body -->
</div>
	<style>
.btn-translatefile {
	position: absolute;
	height: 34px;
	opacity: 0;
	cursor: pointer;
}

img[src=''] {
	display: none;
}

img.uplaod {
	height: 120px;
	margin-left: 10px;
}

.version-list {
	display: none;
}
</style>
<!-- /.box -->
<script type="text/javascript" src="/static/js/ajaxfileupload.js"></script>
<script type="text/javascript">
function ajaxFileUpload(id) {
	var url = '/manage/slide/uploadimg';
	$.ajaxFileUpload({
		url : url, //需要链接到服务器地址
		secureuri : false,
		fileElementId : id, //文件选择框的id属性
		dataType : 'json', //服务器返回的格式，可以是json
		success : function(data, status) {
			//alert(this.fileElementId);
			var that = this;
			if (data.status == '1') {
				$('#file_' + that.fileElementId).attr('src',data.data);
				$('#field_' + that.fileElementId).val(data.data);
			} else {
				alert(data.info);
			}
		},
		error : function(data, status, e) {
			alert(e);
		}
	});
}
		</script>